Help me, how to set each column same height? I have this structure:
<div class="container">
<div class="row">
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
</div>
</div>
In this case, the content displayed is as follows: enter image description here
But when I try to resize the browser window, the content is shifted wrong: enter image description here
And so should: enter image description here
How to fix it?
asked Feb 27, 2015 at 13:04
Ihor Tkachuk
1,1185 gold badges15 silver badges36 bronze badges
-
Possible duplicate - stackoverflow.com/questions/18020360/…Paulie_D– Paulie_D2015年02月27日 13:16:31 +00:00Commented Feb 27, 2015 at 13:16
-
min-height min-heightknitevision– knitevision2015年02月27日 14:27:50 +00:00Commented Feb 27, 2015 at 14:27
-
@knitevision, What do you mean?Ihor Tkachuk– Ihor Tkachuk2015年02月27日 14:35:44 +00:00Commented Feb 27, 2015 at 14:35
-
@Pearson sorry i thought you mean having same height o_Oknitevision– knitevision2015年02月27日 14:38:36 +00:00Commented Feb 27, 2015 at 14:38
2 Answers 2
One way would be to add a clearfix that's only visible on the smaller viewports..
<div class="container">
<div class="row">
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
<div class="clearfix visible-sm"></div>
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
<div class="col-md-3 col-sm-6">
<!--content-->
</div>
</div>
</div>
answered Feb 27, 2015 at 13:34
Carol Skelly
364k92 gold badges741 silver badges651 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
create a custom css class in your .css file
.fixed-height {
height: 200px;
}
Then add this to your HTML as follows:
<div class="container">
<div class="row">
<div class="col-md-3 col-sm-6 fixed-height">
<!--content-->
</div>
<div class="col-md-3 col-sm-6 fixed-height">
<!--content-->
</div>
<div class="col-md-3 col-sm-6 fixed-height">
<!--content-->
</div>
<div class="col-md-3 col-sm-6 fixed-height">
<!--content-->
</div>
</div>
</div>
answered Feb 27, 2015 at 13:56
contool
1,0643 gold badges19 silver badges29 bronze badges
2 Comments
contool
you could get more complex and customise the fixed-height class based on screen size - but above works across all situations
contool
umm... sorry but this works, and addresses the question exactly so why the downvote? bootply.com/QCh2TiB8cx
lang-html